﻿
CREATE FUNCTION [dbo].[ColorOptions]()
RETURNS TABLE AS RETURN
SELECT TOP 100 PERCENT value=Name,
	style='BACKGROUND-COLOR:'+Name+(CASE WHEN R+G+B < 300 THEN ';COLOR:white' ELSE '' END),
	Name=Name,RGB=dbo.FormatFix(R/16*16,3)+dbo.FormatFix(G/16*16,3)+dbo.FormatFix(B/16*16,3)
FROM ts_Color
WHERE 0 IN (R,G,B) OR (R=G AND G=B)

